//当前这个模块：AIP进行统一管理
//引入二次封装的axios（带有请求、响应的拦截器）
import requests from './request';
import mockAjax from './mockAjax';
// import mockjs from 'mockjs';


//三级联动接口
//请求地址：/api/product/getBaseCategoryList    get:无
//发送请求:axion发请求返回结果Promise对象


export const reqCategoryList = () => requests({ url: '/product/getBaseCategoryList', method: 'get' })
//获取banner（Home首页轮播的接口）
export const reqGetBannerList = () => mockAjax.get('/banner');
//获取floor数据
export const reqFloorList = () => mockAjax.get('/floor');

//获取Search搜索块数据 地址为/api/list  请求方式为post    
//当前这个接口给服务器传递参数params，至少是一个空对象****调用这个函数的时候，params至少是一个空对象
export const reqGetSearchInfo = (params) => requests({ url: '/list', method: 'post', data: params })


export const reqGoodInfo = (skuId) => requests({ url: `/item/${skuId}`, method: 'get' });

export const reqAddOrUpdateShopCart = (skuId, skuNum) => requests({ url: `/cart/addToCart/${skuId}/${skuNum}`, method: 'post' })

export const reqCartList = () => requests({ url: "/cart/cartList", method: 'get' });

export const reqDeleteCartById = (skuId) => requests({ url: `/cart/deleteCart/${skuId}`, method: 'DELETE' })

// export const reqUpdateCheckedById = (skuId, isChecked) => requests({ url: `/cart/checkCart/${skuId}/${isChecked}`, method: 'get' })
export const reqUpdateCheckedById = (skuId, isChecked) => requests({ url: `/cart/checkCart/${skuId}/${isChecked}`, method: 'get' })


//注册请求接口:
export const reqGetCode = (phone) => requests({ url: `/user/passport/sendCode/${phone}`, method: 'get' })

//注册用户：
export const reqUserRegister = (data) => requests({ url: `/user/passport/register`, method: 'post', data });

//登录接口:
export const reqUserLogin = (data) => requests({ url: `/user/passport/login`, method: 'post', data });

//获取用户登录信息
export const reqUserInfo = () => requests({ url: '/user/passport/auth/getUserInfo', method: 'get' });

//退出登录
export const reqLoginOut = () => requests({ url: '/user/passport/logout', method: 'get' })

//获取用户地址信息
export const reqAddressInfo = () => requests({ url: '/user/userAddress/auth/findUserAddressList', method: 'get' })

//获取订单交易页信息
export const reqOrderInfo = () => requests({ url: '/order/auth/trade', method: 'get' })


export const reqSubmitOrder = (tradeNo, data) => requests({ url: `/order/auth/submitOrder?tradeNo=${tradeNo}`, method: 'post', tradeNo, data })


// /payment/weixin/createNative/{orderId}
export const reqPayInfo = (orderId) => requests({ url: `/payment/weixin/createNative/${orderId}`, method: 'get', orderId })